﻿@using E5_KhuyenMaiVang.Models;
@model IEnumerable<DEAL>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    int nDeal = Model.Count();
    List<int> SoldQuantities = ViewBag.SoldQuantities;
    double TongThu = 0;
}

@section menu
{
    <h3>Admin</h3>
    <ul class="nav">        
        <li><a href="@Url.Action("TKDT_Thang","Admin")" style="text-decoration:underline; font-weight:bold;">Doanh thu theo tháng</a></li>
        <li><a href="@Url.Action("TKDT_KhuyenMai","Admin")">Doanh thu khuyến mãi</a></li>
        <li><a href="@Url.Action("TKDT_DoanhNghiep","Admin")">Doanh thu doanh nghiệp</a></li>
   </ul>
}


<div class="top-bar">                   
    <h1>THỐNG KÊ DOANH THU</h1>
    <div class="breadcrumbs"><a href="#">Thống kê</a> / <a href="#">Doanh thu theo tháng</a></div>
</div>
<form  method="post" action="@Url.Action("SearchTKDT_Thang", "Admin")">
<div class="select-bar">
    <label>
        <select name="Month">
            <option value="0">---</option>
            @for(int i =1;i<13;i++){
                if(i!=ViewBag.SelectedMont){
                    <option value="@i">@i</option>
                }else{
                    <option value="@i" selected="true">@i</option>
                }
            }
        </select>/           
    </label>
    @if (ViewBag.SelectedYear != 0)
    {
     <input type="text" name="Year" value="@ViewBag.SelectedYear" maxlength="4"/>
    }
    else { 
        <input type="text" name="Year" maxlength="4"/> 
    }
    <label>
        <input type="submit" value="Search" />
    </label>
</div>
</form>
<div class="table">
<table class="listing" cellpadding="0" cellspacing="0">
        <tr>
            <th width="69">Số thứ tự</th>
            <th width="194">Tên khuyến mãi</th>
            <th width="117">Doanh nghiệp</th>
            <th width="39">Giá</th>
            <th width="112">Số lượng bán</th>
            <th width="80">Tiền thu</th>
        </tr>
        @for (int i = 0; i < nDeal; i++)
        {
            double TienThu = SoldQuantities[i] * Model.ElementAt(i).Discount;
            TongThu += TienThu;
        <tr>
            <td class="style1">@(i + 1) </td>
            <td>@Model.ElementAt(i).DealName</td>
            <td>@Model.ElementAt(i).COMPANY.CompanyName</td>
            <td>@Model.ElementAt(i).Discount</td>
            <td>@SoldQuantities[i]</td>
            <td>@TienThu</td>
                           
        </tr>
        }
    </table>
    <div class="select">
        <strong>Tổng doanh thu: </strong>
        <strong style="color:#F00;">@TongThu</strong>
    </div>
</div>
            